<?php
$this->renderPartial('/order/waypoint', array('point' => 2));

if(!isset($customer))
	$customer = new Customer;

if(!isset($deliveryAddress))
	if(isset($customer->deliveryAddress))
		$deliveryAddress = $customer->deliveryAddress;
	else
		$deliveryAddress = new DeliveryAddress;

if(!isset($this->breadcrumbs))
	$this->breadcrumbs = array(
			Shop::t('Order'),
			Shop::t('Shipping method'));
			
$form=$this->beginWidget('CActiveForm', array(
			'id'=>'customer-form',
			'action' => array('//shop/order/create&cart_id='.$_GET['cart_id']),
			'enableAjaxValidation'=>false,
			)); 
?>



<h3> </h3>

<?php 
$add = $customer->address;

?>
<div class="address-detail">
    <div class="current_address">  
            <p class="choose-other-de radius-5px"><?php echo Shop::t('Shipping address'); ?></p>
            <div class="name"><span>Khách hàng :</span> <?php echo $add->firstname; ?></div>
            <div class="name"><?php echo $add->address.' - '.$add->province; ?></div>
        </div>
    
    <div class="current_address">
        <?php 
    //        $this->widget('zii.widgets.CDetailView', array(
    //                'data'=>$customer->address,
    //                'htmlOptions' => array('class' => 'detail-view'),
    //                'attributes'=>array(
    //                    'firstname',
    //                    'lastname',
    //                    'address',
    //                    'province',
    //                    ),
    //                ));
            ?>
    </div>
    
    <div class="choose-other-de radius-5px">
            <?php echo CHtml::checkBox('toggle_delivery',
                                         $customer->deliveryAddress !== NULL, 
                                        array('style' => 'float: left'));
            echo CHtml::label(Shop::t('alternative delivery address'), 'toggle_delivery', array(
                        'style' => 'cursor:pointer'));
            
        ?></div>
    
    <div class="form">
        <fieldset id="delivery_information" style="display: none;">
            <div class="payment_address">
    
                <h3> <?php echo Shop::t('new shipping address'); ?> </h3>
                <p><?php echo Shop::t('Shipping new address'); ?></p>
                
                <div class="row">
                    <?php echo $form->labelEx($deliveryAddress,'firstname'); ?>
                    <?php echo $form->textField($deliveryAddress,'firstname',array('size'=>45,'maxlength'=>45)); ?>
                    <?php echo $form->error($deliveryAddress,'firstname'); ?>
                </div>
            
                <div class="row">
                    <?php echo $form->labelEx($deliveryAddress,'lastname'); ?>
                    <?php echo $form->textField($deliveryAddress,'lastname',array('size'=>45,'maxlength'=>45)); ?>
                    <?php echo $form->error($deliveryAddress,'lastname'); ?>
                </div>
                
                <div class="row">
                    <?php echo $form->labelEx($deliveryAddress,'address'); ?>
                    <?php echo $form->textField($deliveryAddress,'address',array('size'=>45,'maxlength'=>45)); ?>
                    <?php echo $form->error($deliveryAddress,'address'); ?>
                </div>
    
                <div class="row">   
                    <?php echo $form->labelEx($deliveryAddress,'province'); ?>
                    <?php echo $form->dropDownList($deliveryAddress,'province',Shop::getProvince()); ?>
                    <?php echo $form->error($deliveryAddress,'province'); ?>
                </div>
            </div>
        </fieldset>
</div>
</div>
<div class="shipping-me">
    <h3 class="choose-other-de radius-5px"> <?php echo Shop::t('Choose your Shipping method'); ?> </h3>


<?php
$i = 0;

foreach(TransporterMethod::model()->findAll() as $method) {
	echo '<div class="row">';
	echo CHtml::radioButton("ShippingMethod", $i == 0, array(
				'value' => $method->id));
	echo CHtml::label($method->title, 'ShippingMethod').' - ';
	echo CHtml::tag('span', array(), $method->description).' - ';
	echo CHtml::tag('span', array('class'=>'price-s'), Shop::t('Price: ') . $method->unit_price.'/'.$method->unit);
	echo '</div>';
	echo '<div class="clear"></div>';
	$i++;
}
	?>
    
</div>


	

<?php
 Yii::app()->clientScript->registerScript('toggle', "
	if($('#toggle_delivery').attr('checked'))
		$('#delivery_information').show();
	$('#toggle_delivery').click(function() { 
		$('#delivery_information').toggle(500);
	});
");
?>

    <div class="row buttons">
		<?php
        	echo CHtml::submitButton(Shop::t('Continue'),array('id'=>'next'));
        ?>
	</div>

<?php $this->endWidget(); ?>